<?php

namespace Biz\Staff;
use Biz\Transaction;
class Staff extends \Base\BaseBiz
{
    /**
     * @param $staffInfo
     * @return mixed
     */
    public static function insert($staffInfo)
    {
        $staff_orm = new \Orm\Staff\StaffClass();
        $staff_orm['account'] = $staffInfo['account'];
        $staff_orm['name'] = $staffInfo['name'];
        $staff_orm['pwd'] = $staffInfo['pwd'];
        $staff_orm['tel'] = $staffInfo['tel'];
        $staff_orm['email'] = $staffInfo['email'];
        $staff_orm['admin_id'] = $staffInfo['admin_id'];
        $staff_orm['enterprise_role_id'] =  $staffInfo['enterprise_role_id'];
        $staff_orm['remark'] =  $staffInfo['remark'];
        $staff_orm['type'] =  $staffInfo['type'];
        $staff_orm->insert();
        return $staff_orm['id'];
    }

    public static function update($staffInfo){
        $staff_orm = new \Orm\Staff\StaffClass();
        $staff_orm['account'] = $staffInfo['account'];
        $staff_orm['pwd'] = $staffInfo['pwd'];
        $staff_orm['name'] = $staffInfo['name'];
        $staff_orm['tel'] = $staffInfo['tel'];
        $staff_orm['email'] = $staffInfo['email'];
        $staff_orm['enterprise_role_id'] =  $staffInfo['enterprise_role_id'];
        $staff_orm['id'] = $staffInfo['id'];
        $staff_orm['is_use'] = $staffInfo['is_use'];
        $staff_orm['is_use'] = $staffInfo['is_use'];
        $staff_orm['country'] = $staffInfo['country'];
        $staff_orm['province'] = $staffInfo['province'];
        $staff_orm['city'] = $staffInfo['city'];
        $staff_orm['area'] = $staffInfo['area'];
        $staff_orm['address'] = $staffInfo['address'];
        $staff_orm['type'] = $staffInfo['type'];
        $staff_orm['remark'] = $staffInfo['remark'];
        return $staff_orm->update();
    }

    /**
     * @param $account
     * @param $pwd
     */
    public static function login($account)
    {
        $model = new \Orm\Staff\StaffModel();
        return $model->loadByLoginAccount($account);
    }
}